package ModelLayer;


/**
 * Write a description of class SalesLineItem here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class SalesLineItem
{
    private Product product ;
    private int amount;
    public SalesLineItem(Product i_product, int i_amount)
    {
        product = i_product;
        amount = i_amount;
    }
    
    private double calculate_total_cost()
    {
         double price = product.get_price();
         int pieces_in_palette = product.get_pieces_in_palette();
         double price_per_palette = product.get_price_for_palette();
         int palettes = amount / pieces_in_palette;
         int singles = amount % pieces_in_palette;
         return singles * price + palettes * price_per_palette;
    }
    
    public double get_total_cost()
    {
        return calculate_total_cost();
    }
    
    public double get_discounted_cost()
    {
        double temp_cost = calculate_total_cost();
        if(product.get_amount_qualified_for_discount() <= amount)
        {
            temp_cost *= (1 - product.get_discount() / 100);
        }   
        return temp_cost;
    }
    
    public String get_id()
    {
        return product.get_art_nr();
    }
    
    public int get_amount()
    {
        return amount;
    }
    
    public Object[] give_array()
    {
    	Object[] data = {product.get_art_nr(), amount, get_discounted_cost()};
    	return data;
    }
    
    
}
